<%--
  Created by IntelliJ IDEA.
  User: 22936
  Date: 2022/5/10
  Time: 21:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户信息页</title>
    <link rel="shortcut icon" type="image/x-icon" href="../../static/img/book.ico">
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            width: 100%;
            height: 80%;
            background: url("jsp/../../static/img/2.jpeg");
            background-size: 100%;
        }

        h3 {
            text-align: center;
            margin: 10% auto 0;
            color: whitesmoke;
        }

        form {
            width: 25%;
            height: 60%;
            margin: 3% auto 0;
            overflow: hidden;
            color: transparent;
        }

        .data_span {
            display: inline-block;
            width: 100%;
            height: 20%;
            margin-left: 20%;
            color: azure;
            margin-bottom: 20px;
        }

        .data_span input {
            display: inline-block;
            width: 50%;
            height: 25px;
            border: deepskyblue solid 1px;
            border-radius: 5px;
        }

        .btn_span {
            display: inline-block;
            width: 100%;
            height: 20%;
            margin-left: 20%;
        }

        .btn_span input {
            margin-right: 35px;
            color: white;
            border: none;
            border-bottom: solid 2px deepskyblue;
            border-radius: 5px;
            background-color: transparent;
        }

        form:hover .btn_span input {
            cursor: pointer;
        }
    </style>
</head>
<body>
<h3>你的信息</h3>
<form method="post">
    <span class="data_span">用户名：<input type="text" disabled value="${requestScope.get('uName')}"></span>
    <span class="data_span">密&nbsp;&nbsp;&nbsp;码：<input type="text" class="input_updateUserInfo" value="${requestScope.get('pwd')}" disabled="disabled" ><%----%>
        <input type="text" style="visibility: hidden" class="user_id" value="${requestScope.get('id')}">
    </span>
    <span class="btn_span">
        <input type="button" onclick="submitCheck()" class="input_updateUserInfo" value="确认修改">
        <input type="button" onclick="update()" value="修改">
        <input type="reset" value="取消">
        <input type="button" onclick="goBack()" value="返回">
    </span>
</form>
</body>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.4.1.min.js"></script>
<script>
    function submitCheck() {
        let flag = $(".input_updateUserInfo").prop("disabled");
        console.log(flag);
        if (flag) {
            alert("请先点击修改");
        } else {
            $.post({
                url: "${pageContext.request.contextPath}/user/updatePwd",
                data: {"uId":$(".user_id").val(),"uPassword":$(".input_updateUserInfo").val()},
                success:function (data) {
                    alert(data);
                }
            });
        }
    }

    function update() {
        let show = confirm("是否进行修改操作？");
        if (show === true) {
            $(".input_updateUserInfo").prop("disabled", false);
        }
    }
    function goBack() {
        window.history.go(-1);
    }
</script>
</html>
